package com.suse.lhw.hms.foodserver.service.Impl;

import com.suse.lhw.hms.foodserver.constant.PackageStatusConst;
import com.suse.lhw.hms.foodserver.domin.FFoodmodel;
import com.suse.lhw.hms.foodserver.domin.FUnit;
import com.suse.lhw.hms.foodserver.pojo.input_POJO.modelAndUnits;
import com.suse.lhw.hms.foodserver.pojo.output_POJO.ofm_selectFoodIfoByModelId;
import com.suse.lhw.hms.foodserver.service.FUnitService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import com.suse.lhw.hms.foodserver.dao.FPackageToFFoodmodelMapper;
import com.suse.lhw.hms.foodserver.domin.FPackageToFFoodmodel;
import com.suse.lhw.hms.foodserver.service.FPackageToFFoodmodelService;

import java.util.ArrayList;
import java.util.List;

/**
 * @ProjectName: health_manage_system
 * @Package: com.suse.lhw.hms.foodserver.service.Impl
 * @ClassName: FPackageToFFoodmodelServiceImpl
 * @Description: java类作用描述
 * @Author: 李鸿炜
 * @CreateDate: 2020/4/18 19:30
 * @UpdateUser: 更新者
 * @UpdateDate: 2020/4/18 19:30
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
@Service
public class FPackageToFFoodmodelServiceImpl implements FPackageToFFoodmodelService {

    @Resource
    private FPackageToFFoodmodelMapper fPackageToFFoodmodelMapper;
    @Resource
    private FUnitService fUnitService;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return fPackageToFFoodmodelMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(FPackageToFFoodmodel record) {
        return fPackageToFFoodmodelMapper.insert(record);
    }

    @Override
    public int insertSelective(FPackageToFFoodmodel record) {
        return fPackageToFFoodmodelMapper.insertSelective(record);
    }

    @Override
    public FPackageToFFoodmodel selectByPrimaryKey(Integer id) {
        return fPackageToFFoodmodelMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(FPackageToFFoodmodel record) {
        return fPackageToFFoodmodelMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(FPackageToFFoodmodel record) {
        return fPackageToFFoodmodelMapper.updateByPrimaryKey(record);
    }

    @Override
    public int addAModelOfPackage(int packageId, int modelId) {
        FPackageToFFoodmodel fpt = new FPackageToFFoodmodel(packageId, modelId);
        return fPackageToFFoodmodelMapper.insertSelective(fpt);
    }

    @Override
    public int deleteAModelOfPackage(int packageId, int modelId) {
        FPackageToFFoodmodel ptm = fPackageToFFoodmodelMapper.selectPtmByPackageIdAndModelId(packageId, modelId);
        //开始清理门户
        return fPackageToFFoodmodelMapper.deleteByPrimaryKey(ptm.getId());
    }
}
